package com.yunhe.sms.view.teacher;

import com.yunhe.sms.control.TeacherController;
import com.yunhe.sms.dao.TeacherDao;
import com.yunhe.sms.mode.Teacher;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.function.BiConsumer;

public class TeacherList {
    public static int teacherListUI(List<Teacher> teacherList){
        System.out.println("********************学员信息管理系统-讲师管理********************");
        System.out.println("工号\t\t姓名\t\t年龄\t\t性别\t电话");
        teacherList.forEach(teacher->System.out.println(teacher.getId()+"\t\t"+teacher.getName()+"\t\t"+teacher.getAge()+"\t\t"+teacher.getSex()+"\t"+teacher.getPhone()));
        System.out.println("1.添加讲师\t\t2.修改讲师\t3.删除讲师\t4.返回主页\t\t5.刷新");
        System.out.print("请输入操作码:");
        Scanner sc = new Scanner(System.in);
        try{
            int i = sc.nextInt();
            if(i < 1 || i >5){
                throw new Exception("操作码未识别！");
            }
            return i;
        }catch (Exception e){
            String msg = e.getMessage();   //得到 异常提示信息
            System.out.println(null != msg ? msg : "输入不合法!");
            return teacherListUI(teacherList);
        }
    }
}
